<template>
  <view class="containerx">
    <!-- 景点图片 -->
    <view class="spot-image">
      <image :src="IMAGE_BASE + spotInfo.image" mode="scaleToFill"></image>
    </view>

    <!-- 景点信息 -->
    <view class="spot-info" style="border: 1px solid cadetblue;">
      <view class="spot-header">
        <view class="spot-name">{{ spotInfo.spotName }}</view>
        <view class="spot-price">
          <text class="price">¥{{ spotInfo.ticketPrice }}</text>
          <text class="label">起</text>
        </view>
      </view>

      <view class="info-item">
        <view class="item-label">
          <uni-icons type="location" size="16" color="#666"></uni-icons>
          <text>景点地址</text>
        </view>
        <view class="item-content">{{ spotInfo.address }}</view>
      </view>

      <view class="info-item">
        <view class="item-label">
          <uni-icons type="calendar" size="16" color="#666"></uni-icons>
          <text>开放时间</text>
        </view>
        <view class="item-content">{{ spotInfo.openTime }}</view>
      </view>
    </view>

    <!-- 景点描述 -->
    <view class="spot-desc">
      <view class="section-title">景点介绍</view>
      <view class="desc-content">{{ spotInfo.description }}</view>
    </view>

    <!-- 底部操作栏 -->
    <view class="bottom-bar">
      <view class="price-box">
        <text class="price">¥{{ spotInfo.ticketPrice }}</text>
        <text class="label">起</text>
      </view>
      <button class="book-btn" @click="handleBook">联系电话</button>
    </view>
  </view>
</template>

<script>
import config from '../../api/config.js'
import { getSpotDetail } from '@/api/spots.js'

export default {
  data () {
    return {
      spotId: null,
      spotInfo: {},
      IMAGE_BASE: config.image_base
    }
  },
  onLoad (options) {
    this.spotId = options.id
    this.getSpotInfo()
  },
  methods: {
    getSpotInfo () {
      getSpotDetail(this.spotId).then(res => {
        if (res.code === 200) {
          this.spotInfo = res.data
        }
      })
    },
    handleBook () {
      // TODO: 实现预订功能
      uni.showToast({
        title: '咨询173xxxxxxxx',
        icon: 'none'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.containerx {
  padding-bottom: 120rpx;
}

.spot-image {
  width: 100%;
  height: 500rpx;

  image {
    width: 100%;
    height: 100%;
  }
}

.spot-info {
  background: #fff;
  padding: 30rpx;
  margin-top: -50rpx;
  border-radius: 30rpx 30rpx 0 0;
  position: relative;
}

.spot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30rpx;
}

.spot-name {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
}

.info-item {
  margin-bottom: 20rpx;

  .item-label {
    display: flex;
    align-items: center;
    margin-bottom: 10rpx;
    color: #666;
    font-size: 28rpx;

    text {
      margin-left: 10rpx;
    }
  }

  .item-content {
    color: #333;
    font-size: 28rpx;
    padding-left: 34rpx;
  }
}

.spot-desc {
  background: #fff;
  padding: 30rpx;
  margin-top: 20rpx;

  .section-title {
    font-size: 32rpx;
    font-weight: bold;
    margin-bottom: 20rpx;
  }

  .desc-content {
    font-size: 28rpx;
    color: #666;
    line-height: 1.6;
  }
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100rpx;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30rpx;
  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.price-box {
  .price {
    font-size: 40rpx;
    color: #f56c6c;
    font-weight: bold;
  }

  .label {
    font-size: 24rpx;
    color: #999;
    margin-left: 4rpx;
  }
}

.book-btn {
  background: #f56c6c;
  color: #fff;
  width: 240rpx;
  height: 80rpx;
  line-height: 80rpx;
  border-radius: 40rpx;
  font-size: 28rpx;
  margin: 0;

  &:after {
    border: none;
  }
}
</style>